/*
day289
2020.6.12
*/
#include<iostream>
#include<vector> 
#include<algorithm>
using namespace std;
 
class Solution {
public:
    int smallestDifference(vector<int>& a, vector<int>& b) {
    	using UI=unsigned int;
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		
		int pa=0,pb=0;
		int size_a=a.size(),size_b=b.size();
		long res=INT_MAX;
		while(pa<a.size() && pb<b.size())
		{
			res=min(res,abs((long)b[pb]-(long)a[pa]));
			if(a[pa]<b[pb])
			{
				pa++;
			}
			else
			{
				pb++;
			}
		}
		
		return res;
    }
};

int main()
{
	return 0;
}
